package com.write.program.util;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2019-11-21
 * Time: 23:01
 */
public class StringUtils {

    public static boolean isBlank(String string) {
        return string == null || string.trim().length() == 0;
    }

    public static boolean isNotBlank(String string) {
        return !isBlank(string);
    }

    public static String trim(String string) {
        return string == null ? "" : string.trim();
    }

    public static String trimToNull(String string) {
        if (isBlank(string)) {
            return null;
        }
        return string.trim();
    }

    public static boolean equals(String stringOne, String stringTwo) {
        if (stringOne == null && stringTwo == null) {
            return true;
        } else if (stringOne != null && stringTwo != null) {
            return stringOne.equals(stringTwo);
        } else {
            return false;
        }
    }

    public static boolean equalsIgnoreCase(String stringOne, String stringTwo) {
        if (stringOne == null && stringTwo == null) {
            return true;
        } else if (stringOne != null && stringTwo != null) {
            return stringOne.toLowerCase().equalsIgnoreCase(stringTwo.toLowerCase());
        } else {
            return false;
        }
    }
}
